package com.unchartedskies
{
	import com.gamesmile.framework.util.Log;
	import com.unchartedskies.controller.command.AccueilCommand;
	import com.unchartedskies.controller.command.CreditsCommand;
	import com.unchartedskies.controller.command.LobbyCommand;
	import com.unchartedskies.controller.command.LoginCommand;
	import com.unchartedskies.controller.command.PlayerIOCommand;
	import com.unchartedskies.controller.event.AccueilClickEvent;
	import com.unchartedskies.controller.event.CreditsClickEvent;
	import com.unchartedskies.controller.event.LobbyClickEvent;
	import com.unchartedskies.controller.event.LoginClickEvent;
	import com.unchartedskies.controller.event.PlayerIOEvent;
	import com.unchartedskies.model.State;
	import com.unchartedskies.model.service.PlayerIOService;
	import com.unchartedskies.view.Accueil;
	import com.unchartedskies.view.AccueilMediator;
	import com.unchartedskies.view.Credits;
	import com.unchartedskies.view.CreditsMediator;
	import com.unchartedskies.view.Lobby;
	import com.unchartedskies.view.LobbyMediator;
	import com.unchartedskies.view.Login;
	import com.unchartedskies.view.LoginMediator;
	import com.unchartedskies.view.Main;
	import com.unchartedskies.view.MainMediator;
	
	import flash.display.DisplayObjectContainer;
	
	import org.robotlegs.base.ContextEvent;
	import org.robotlegs.mvcs.Context;
	
	public class UnchartedSkiesContext extends Context
	{
		public function UnchartedSkiesContext(contextView:DisplayObjectContainer=null, autoStartup:Boolean=true)
		{
			super(contextView);
		}
		
		override public function startup():void
		{
			injector.mapSingletonOf(State,State);
			injector.mapSingletonOf(PlayerIOService, PlayerIOService);

			commandMap.mapEvent(AccueilClickEvent.ACCUEIL_CLICKED, AccueilCommand, AccueilClickEvent);
			commandMap.mapEvent(LoginClickEvent.LOGIN_CLICKED, LoginCommand, LoginClickEvent);
			commandMap.mapEvent(CreditsClickEvent.CREDITS_CLICKED, CreditsCommand, CreditsClickEvent);
			commandMap.mapEvent(LobbyClickEvent.LOBBY_CLICKED, LobbyCommand, LobbyClickEvent);
			
			commandMap.mapEvent(PlayerIOEvent.CONNECTED, PlayerIOCommand,PlayerIOEvent);
			commandMap.mapEvent(PlayerIOEvent.CONNECTING, PlayerIOCommand, PlayerIOEvent);
			
			mediatorMap.mapView(Main, MainMediator);
			mediatorMap.mapView(Accueil, AccueilMediator);
			mediatorMap.mapView(Login, LoginMediator);
			mediatorMap.mapView(Credits, CreditsMediator);
			mediatorMap.mapView(Lobby, LobbyMediator);
			
		
			//Start
			Log.debug(this,"Startup");
			contextView.addChild(new Main);
			super.startup();
		}
		

	}
}